package com.consumer.user.controller;

import com.common.consumer.controller.AbstractConsumerGenericController;
import com.common.consumer.service.ConsumerGenericService;
import com.consumer.user.service.ConsumerTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 类描述：菜单的消费者controller
 *
 * @author linzf
 */
@RestController
@RequestMapping("/tree")
public class ConsumerTreeController extends AbstractConsumerGenericController {

    @Autowired
    private ConsumerTreeService consumerTreeService;

    @Override
    protected ConsumerGenericService getService() {
        return this.consumerTreeService;
    }

    /**
     * 功能描述：更新按钮节点状态
     * @param entity
     * @return
     */
    @PostMapping("operateTreeButton")
    public Map<String,Object> operateTreeButton(@RequestBody Map<String,Object> entity){
        return consumerTreeService.operateTreeButton(entity);
    }

    /**
     * 功能描述：获取数据字典的分页的数据
     * @param query
     * @return
     */
    @PostMapping("queryTreeButtonList")
    public Map<String,Object> queryTreeButtonList(@RequestBody Map<String,Object> query){
        return consumerTreeService.queryTreeButtonList(query);
    }

    /**
     * 功能描述：获取所有的树形菜单的数据
     * @return
     */
    @PostMapping("getAllTreeList")
    public Map<String,Object> getAllTreeList(){
        return consumerTreeService.getAllTreeList();
    }
}
